﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLCMS.Web.Wap.Code;
using DotNet.Common.Command;
using ZLCMS.Business.Shop.Commands.Order;
using DotNet.Common.NHibernateUtil;
using ZLCMS.Data.Model;
using NHibernate;
using ZLCMS.Web.SystemManage.Basics.ProductSKU;
using Newtonsoft.Json;
using NHibernate.Criterion;
using ZLCMS.Business.Shop.Data;

namespace ZLCMS.Web.ShopCart
{
    public partial class ShoppingCartComfirmSuccess : WebMemberPageBase
    {
        public ShopOrderInfo _order;

        protected void Page_Load(object sender, EventArgs e)
        {
            CommandResult res = new LoadOrderDetailCommand().Execute(new LoadOrderDetailParameter() { OrderNo = Request["orderno"] }) as CommandResult;
            rpt_pro.DataSource = res.Result;
            rpt_pro.DataBind();
        }

        public string GetSkuItemHtml(string skuProductNo)
        {
            using (ISession session = SessionFactoryHelper.CreateSession())
            {
                _order = session.CreateCriteria<ShopOrderInfo>().Add(Expression.Eq("OrderNo", Request["orderno"])).UniqueResult<ShopOrderInfo>();

                ShopSkuProduct product = session.CreateQuery("from ShopSkuProduct where ProductSkuCode=:code ").SetParameter("code", skuProductNo).UniqueResult<ShopSkuProduct>();

                List<SKUGroup> grouplist = JsonConvert.DeserializeObject<List<SKUGroup>>(product.ParamCode);
                string itemList = "";
                foreach (SKUGroup cd in grouplist)
                {
                    itemList += "<span>[" + cd.ItemName + "]</span> ";
                }

                return itemList;
            }
        }
    }
}